﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace blackhouse.WebNemo.Business.Groups {
    public class Group : IGroup {

        #region Fields

        protected IGroup decoGroup;

        #endregion

        #region Properties

        public int Id {
            get { return this.decoGroup.Id; }
        }

        public string Identyficator {
            get {
                return this.decoGroup.Identyficator;
            }
            set {
                this.decoGroup.Identyficator = value;
            }
        }

        public string Name {
            get {
                return this.decoGroup.Name;
            }
            set {
                this.decoGroup.Name = value;
            }
        }

        public string SystemName {
            get { return this.decoGroup.SystemName; }
        }

        public bool Exists {
            get { return this.decoGroup.Exists; }
        }

        public GroupColumnCollection Columns {
            get { return this.decoGroup.Columns; }
        }

        public string SelectTable {
            get { return this.decoGroup.SelectTable; }
        }

        public GroupType Type {
            get { return this.decoGroup.Type; }
        }

        public bool EnableTranslate {
            get {
                return this.decoGroup.EnableTranslate;
            }
            set {
                this.decoGroup.EnableTranslate = value;
            }
        }

        public bool ReadOnly {
            get {
                return this.decoGroup.ReadOnly;
            }
            set {
                this.decoGroup.ReadOnly = value;
            }
        }

        #endregion

        #region Constructors

        public Group(int groupId) {
            this.decoGroup = Factory.Instance().GetGroup(groupId);
        }

        #endregion

        #region Methods

        public void Save() {
            this.decoGroup.Save();
        }

        public void Delete() {
            this.decoGroup.Delete();
        }

        public IGroupRecord[] GetGroupRecords() {
            return this.GetGroupRecords(CultureInfo.CurrentCulture);
        }

        public IGroupRecord[] GetGroupRecords(CultureInfo language) {
            return this.decoGroup.GetGroupRecords(language);
        }

        public IGroupRecord[] GetGroupRecords(GroupRecordQuery query) {
            return this.GetGroupRecords(query, CultureInfo.CurrentCulture);
        }

        public IGroupRecord[] GetGroupRecords(GroupRecordQuery query, CultureInfo language) {
            return this.decoGroup.GetGroupRecords(query, language);
        }

        public IGroupRecord GetGroupRecord(int recordId) {
            return this.GetGroupRecord(recordId, CultureInfo.CurrentCulture);
        }

        public IGroupRecord GetGroupRecord(int recordId, CultureInfo language) {
            return this.decoGroup.GetGroupRecord(recordId, language);
        }

        public IGroupRecord[] GetRelatedGroupRecords(int groupId, string columnName, int recordId) {
            return this.GetRelatedGroupRecords(groupId, columnName, recordId, CultureInfo.CurrentCulture);
        }

        public IGroupRecord[] GetRelatedGroupRecords(int groupId, string columnName, int recordId, CultureInfo language) {
            return this.decoGroup.GetRelatedGroupRecords(groupId, columnName, recordId, language);
        }

        public void RemoveRelationToGroupRecord(int relRecordId, int parentGroupId, string parentColumnName, int parentRecordId) {
            this.decoGroup.RemoveRelationToGroupRecord(relRecordId, parentGroupId, parentColumnName, parentRecordId);
        }

        public void AddRelationToGroupRecord(int relRecordId, int parentGroupId, string parentColumnName, int parentRecordId) {
            this.decoGroup.AddRelationToGroupRecord(relRecordId, parentGroupId, parentColumnName, parentRecordId);
        }

        #endregion

    }
}
